<style lang="scss" scoped>
    @import '../../css/study-plan.scss';
    .head-tab-box{padding: 18px 20px;background: #fff;}
    .head-tab-box span{margin-right: 30px;cursor: pointer;font-size: 14px;}
    .head-tab-checked{color: $mco;border-bottom: 3px solid $mco;}
    .add-plan-word{float: right;color: $mco;margin-top: -16px;cursor: pointer;}
    .add-plan-word .el-icon-plus{font-weight: bold;}
    .kind-box{padding: 24px 20px 0 0}
    .check-box{display: inline-block;}
    .main-card{width:32%;float: left;box-shadow: 0px 2px 4px #ccc;margin-top: 20px;}
    .mar-right{margin-right: 2%;}
    .card-head{padding: 28px 20px 20px 20px;background: #f7f9fa;}
    .card-head div{font-size: 16px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}
    .card-head p{color: #aaa;font-size: 12px;margin: 4px 0 8px 0;@include maxLine(2, 20px);height: 40px;}
    .card-head span{color: #888;font-size: 12px;}
    .card-middle{padding: 12px 20px;background: #fff;height: 330px;overflow-y: auto;}
    .card-middle li{padding: 20px 0;}
    .card-middle img{float: left;width: 30px;height: 30px;border-radius: 100%;margin: 6px 12px 0 0;}
    .card-content p{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}
    .card-content div{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}
    .card-foot{background: #fff;color: #aaa;}
    .card-foot div{font-size: 16px;text-align: center;height: 60px;line-height: 60px;border-top: 1px solid #ccc;float: left;cursor: pointer;}
    .card-foot div:first-child{border-right: 1px solid #fff;width: 49%;}
    .card-foot div:last-child{border-left: 1px solid #ccc;width: 50%}
    .card-foot span{margin-left: 6px;}


    /*应用付费资源弹框内容*/
    .dialog-big-body-car{border: 1px solid #eee;}
    .car-head{padding: 18px 24px;background: #fcfdff}
    .check-all{margin-left: 4px;}
    .car-body{padding: 18px 24px;border-top: 1px solid #eee;background: #fff;}
    .car-body:first-child{border-top: none;}
    .car-content{height: 90px;line-height: 90px;text-align: center;}
    .car-title{text-align: center;}
    .book-info{display:-webkit-box;display: box;}
    .avatar-box-car{display: block;margin-right: 12px;width: 64px;height: 90px;}
    .avatar-box-car img{width: 100%;height: 100%;}
    .author-box{-webkit-box-flex: 1;box-flex: 1;-webkit-flex: 1;flex: 1;}
    .book-name{text-overflow: ellipsis;overflow: hidden;white-space: nowrap;margin-bottom: 30px;padding-top: 8px;}
    .author-name{text-overflow: ellipsis;overflow: hidden;white-space: nowrap;color: #999}
    .count-box{display: inline-block;}

    .count-box-car{display: inline-block;}
    .minus-plus-btn{float: left;border:1px solid #aaa;background: #fcfdff;width: 20px;height: 28px;line-height: 28px;cursor: pointer;text-align: center;}
    .icon-font{font-size: 6px;}
    .book-count{float: left;width: 40px;height: 26px;line-height: 26px;border-left:none;border-right: none; border-top:1px solid #aaa;border-bottom: 1px solid #aaa;text-align: center;outline: none;}
    .count-box-car input[type=text]:focus {border-left:none;border-right: none; border-top:1px solid #aaa;border-bottom: 1px solid #aaa;}
    .singal-price-box{text-align: center;;padding-top: 12px;}
    .singal-price-box1{text-align: center;padding-top: 20px;}
    .singal-price-box2{text-align: center;padding-top: 32px;}
    .line-box{color: #aaa;}
    .line-box span{text-decoration: line-through;}
    .car-foot{padding: 20px 20px 15px 64px;border-top: 1px solid #eee;}
    .car-foot-main{float: right;margin-top: 2px;}
    .resource-num{color: #000;font-weight: bold;padding-right: 10px;}
    .old-price{padding-right: 10px;}
    .dialog-btn-left{width: 150px;margin: 0 10px 0 -4px;}
    .dialog-btn-right{width: 150px;background: $mco;}


    .card-middle{
        //以下针对ie中滚动条设置
        scrollbar-arrow-color: #fff; /**//*三角箭头的颜色*/
        scrollbar-face-color: #ccc; /**//*立体滚动条的颜色*/
        scrollbar-3dlight-color: #fff; /**//*立体滚动条亮边的颜色*/
        scrollbar-highlight-color: #fff; /**//*滚动条空白部分的颜色*/
        scrollbar-shadow-color: #fff; /**//*立体滚动条阴影的颜色*/
        scrollbar-darkshadow-color: #fff; /**//*立体滚动条强阴影的颜色*/
        scrollbar-track-color: #fff; /**//*立体滚动条背景颜色*/
        scrollbar-base-color:#fff; /**//*滚动条的基本颜色*/
    }

    .no-resource{background: #fff;min-height: 500px;text-align: center;padding-top: 160px;}
    .no-word{color: #999;padding: 20px 0 26px;}

</style>

<template>
    <section>

        <div class="head-tab-box">
            <span :class="{'head-tab-checked':headTabID==1}" @click="gotoPath('/study/plan-list')">学习计划</span>
            <span :class="{'head-tab-checked':headTabID==2}">推荐学习计划</span>
            <div class="kind-box">
                <span>分类：</span>
                <div class="check-box">
                    <el-checkbox-group v-model="checkList" @change="getList">
                        <el-checkbox v-for="one in kindList" :label="one.stuTypeID" :key="one.stuTypeID">{{one.stuTypeName}}</el-checkbox>
                    </el-checkbox-group>
                </div>
            </div>
        </div>
        <div class="main-line clearfix">
            <template  v-for="one,index in list">
                <div class="main-card" :class="{'mar-right':(index+1)%3!=0}">
                    <div class="card-head" @click="gotoInfo(one)">
                        <div>{{one.study?one.study.Title:''}}</div>
                        <p>{{one.study?one.study.Reason:''}}</p>
                        <span>{{one.study?one.study.UsedNum:''}}份订购量</span>
                    </div>
                    <ul class="card-middle" @click="gotoInfo(one)">
                       <li v-for="item in one.task" class="clearfix">
                           <template v-if="item.taskResourceCate&&item.taskResourceCate==1">
                               <img src="../../images/plan-book.png" alt="">
                           </template>
                           <template v-if="item.taskType==2">
                               <img src="../../images/plan-test.png" alt="">
                           </template>
                           <template v-if="item.taskType==3">
                               <img src="../../images/plan-question.png" alt="">
                           </template>
                           <template v-if="item.taskResourceCate&&item.taskResourceCate==2">
                               <img src="../../images/plan-course.png" alt="">
                           </template>
                           <div class="card-content">
                               <p :class="{'mt':item.taskType==2||item.taskType==3}">{{item.taskContentTitle}}</p>
                               <div v-show="item.taskType!=2&&item.taskType!=3">作者：{{item.author}}</div>
                           </div>
                       </li>
                    </ul>
                    <div class="card-foot clearfix">
                        <div @click="apply(one)"><i class="el-icon-menu"></i><span>应用</span></div>
                        <div class="info-box" @click="gotoInfo(one)"><i class="el-icon-info"></i><span>详情</span></div>
                    </div>
                </div>
            </template>
        </div>

        <div class="no-resource" v-show="list.length==0">
            <div><img src="../../images/ic-default.png" alt=""></div>
            <p class="no-word">暂无相关分类学习计划</p>
        </div>

        <div v-show="pageInfo.total>15">
            <el-pagination class="mt20 fr"
                           background
                           @size-change="getList"
                           @current-change="getList"
                           :current-page.sync="pageInfo.page"
                           :page-size="pageInfo.pageSize"
                           layout="prev, pager, next, jumper"
                           :total="pageInfo.total">
            </el-pagination>
        </div>

        <el-dialog
                :title="dialogBigCar.title"
                :visible.sync="dialogBigCar.centerDialogVisible"
                width="740px"
                center>
            <div class="dialog-big-body-car">
                <el-row class="car-head">
                    <el-col :span="12"><div class="car-title">资源信息</div></el-col>
                    <el-col :span="6"><div class="car-title">数量</div></el-col>
                    <el-col :span="6"><div class="car-title">单价(元)</div></el-col>
                </el-row>
                <template v-for="one,index in buyCarList">
                    <el-row class="car-body">
                        <el-col :span="2"><div class="car-content"></div></el-col>
                        <el-col :span="10">
                            <div>
                                <div class="book-info">
                                    <div class="avatar-box-car"><img :src="one.resourceCover" alt=""></div>
                                    <div class="author-box">
                                        <div class="book-name">{{one.resourceName}}</div>
                                        <div class="author-name">{{one.author}}</div>
                                    </div>
                                </div>
                            </div>
                        </el-col>
                        <el-col :span="6">
                            <div class="car-content">
                                <div class="count-box">
                                    <span>{{buyCarNum}}</span>
                                </div>
                            </div>
                        </el-col>
                        <el-col :span="6" v-show="recommendSourceID!=0">
                            <div class="singal-price-box2">
                                <div><span>{{Number(one.price1).toFixed(2)}}</span></div>
                            </div>
                        </el-col>
                    </el-row>
                    <!--448到474行为推荐学习计划套餐价内容-->
                    <el-row class="car-body">
                        <el-col :span="12"><div class="car-content"></div></el-col>
                        <el-col :span="6">
                            <div class="singal-price-box2">
                                <span class="count-box-car count-box-top clearfix">
                                    <span class="minus-plus-btn" @click="countMinus"><i class="el-icon-minus icon-font"></i></span>
                                    <input type="text" class="book-count" v-model="buyCarNum" @input="countChange">
                                    <span class="minus-plus-btn" @click="countPlus"><i class="el-icon-plus icon-font"></i></span>
                                </span>
                            </div>
                        </el-col>
                        <el-col :span="6">
                            <div class="singal-price-box" v-show="recommendBuyCar.PriceNumList?recommendBuyCar.PriceNumList.length==3:false">
                                <div :class="{'line-box':Number(buyCarNum)>Number(recommendBuyCar.num1)}">1-{{recommendBuyCar.num1}}份：<span>{{Number(recommendBuyCar.price1).toFixed(2)}}</span></div>
                                <div :class="{'line-box':Number(buyCarNum)<Number(recommendBuyCar.num1)+1||Number(buyCarNum)>Number(recommendBuyCar.num2)}">{{Number(recommendBuyCar.num1)+1}}-{{recommendBuyCar.num2}}份：<span>{{Number(recommendBuyCar.price2).toFixed(2)}}</span></div>
                                <div :class="{'line-box':Number(buyCarNum)<Number(recommendBuyCar.num3)}">≧{{recommendBuyCar.num3}}份：<span>{{Number(recommendBuyCar.price3).toFixed(2)}}</span></div>
                            </div>
                            <div class="singal-price-box1" v-show="recommendBuyCar.PriceNumList?recommendBuyCar.PriceNumList.length==2:false">
                                <div :class="{'line-box':Number(buyCarNum)>Number(recommendBuyCar.num1)}">1-{{recommendBuyCar.num1}}份：<span>{{Number(recommendBuyCar.price1).toFixed(2)}}</span></div>
                                <div :class="{'line-box':Number(buyCarNum)<Number(recommendBuyCar.num2)}">≧{{recommendBuyCar.num2}}份：<span>{{Number(recommendBuyCar.price2).toFixed(2)}}</span></div>
                            </div>
                            <div class="singal-price-box2" v-show="recommendBuyCar.PriceNumList?recommendBuyCar.PriceNumList.length==1:false">
                                <div><span>{{Number(recommendBuyCar.price1).toFixed(2)}}</span></div>
                            </div>
                        </el-col>
                    </el-row>

                    <div class="car-foot clearfix" v-show="index==buyCarList.length-1">
                        <span class="car-foot-main">
                            资源数：<span class="resource-num">{{buyCarList.length}}</span>商品原价：<span class="old-price">￥{{originalPrice.toFixed(2)}}</span>已节省：<span class="resource-num">￥{{(originalPrice-allMoney).toFixed(2)}}</span>合计：<span class="color-orange fw-bold">￥{{allMoney.toFixed(2)}}</span>
                        </span>
                    </div>
                </template>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button class="dialog-btn-left" @click="dialogBigCar.centerDialogVisible = false">取 消</el-button>
                <el-button class="dialog-btn-right" type="primary" @click="account">立即支付</el-button>
            </span>
        </el-dialog>

    </section>

</template>

<script>

import qs from 'qs'

export default{
    data: function(){
        return {
            list:[],
            pageInfo: {
                pageSize: 15,
                total:0,
                page:1
            },
            headTabID:2,
            kindList:[],
            checkList:[],
            tab:[
                {
                    name: '学习计划',
                    type: '0'
                },
                {
                    name: '推荐学习计划',
                    type: '1'
                }
            ],

            path: [
                {
                    'name':'培训学习',
                    'path':'/study/plan-list'
                },
                {
                    'name':'推荐学习计划'
                }
            ],

            dialogBigCar:{
                centerDialogVisible: false,
                title:'资源付费'
            },
            buyCarNum:0,            //增加的份数，默认为部门人数
            buyCarList:[],          //付费资源列表
            originalPrice:0,         //原价
            allMoney:0,               //合计
            recommendSourceID:0,         //是否是推荐计划 （0不是）
            recommendBuyCar:{},            //推荐计划套餐价格的处理容器
            studyID:0                   //应用后获取的学习计划ID
        }
    },
    mixins: [mixinMethods],
    watch:{
        creentTab(value){
            this.page = 1

            value == '0' ? this.$router.push({'path': '/study/plan-list'}) : this.$router.push({'path': '/study/recommend-list'})

        }
    },

    computed: {
        creentTab(){
            return this.$store.state.creentTab
        }
    },

    methods: {
        account(){          //立即支付跳支付页面
            let nowList = [];
            this.buyCarList.forEach(item => {
                nowList.push({ResourceID:item.resourceID,Num:this.buyCarNum})
            })
            axios.post('/com/orders/add', qs.stringify({
                orderGoods:nowList,
                orderType:2,
                relationID:this.studyID
            })).then((res) => {
                var d = res.data;
                if(d.flag == 1){
                    this.$router.push({name:'resourceResourcePay',query:{OID:d.data.OrderID,allCount:this.allMoney}})
                }else {
                    this.$message.error(d.msg)
                }
            })
        },

        apply(one){
            if(one.usedStudyID){
                this.$router.push({name:'studyPlanInfo',query:{studyID:one.usedStudyID}})
            }else {
                axios.post('/com/study/useCommendStudy', qs.stringify({
                    commendStudyID:one.study.CommendID
                })).then((res) => {
                    let dBig = res.data;
                    this.studyID = dBig.data.studyID;
                    if(dBig.flag == 1){
                        this.getList();
                        axios.post('/com/study/resPayList', qs.stringify({
                            studyID:dBig.data.studyID
                        })).then((res) => {
                            let d = res.data;
                            if(d.flag == 1){
                                this.buyCarNum = Number(d.data.buyNum)
                                d.data.detail.forEach(item=>{
                                    item.ResourcePrice = eval("(" + item.resourcePrice + ")");
                                    item.PriceNumList = [];

                                    item.ResourcePrice.forEach((one)=>{
                                        item.PriceNumList.push({price:one.price,countNum:one.num,countBig:String(one.num).split('-')[1]||one.num});
                                    })
                                    item.allPrice = 0;
                                    if(item.PriceNumList.length==3){
                                        item.price1 = item.PriceNumList[0].price;
                                        item.price2 = item.PriceNumList[1].price;
                                        item.price3 = item.PriceNumList[2].price;

                                        item.num1 = Number(item.PriceNumList[0].countBig);
                                        item.num2 = Number(item.PriceNumList[1].countBig);
                                        item.num3 = Number(item.PriceNumList[2].countBig);

                                        item.allPrice = this.buyCarNum<item.num1+1 ? item.allPrice=(this.buyCarNum*item.price1).toFixed(2):this.buyCarNum>item.num3?item.allPrice=(this.buyCarNum*item.price3).toFixed(2):item.allPrice=(this.buyCarNum*item.price2).toFixed(2);
                                    }else if(item.PriceNumList.length==2){
                                        item.price1 = item.PriceNumList[0].price;
                                        item.price2 = item.PriceNumList[1].price;

                                        item.num1 = Number(item.PriceNumList[0].countBig);
                                        item.num2 = Number(item.PriceNumList[1].countBig);

                                        item.allPrice = this.buyCarNum<item.num1+1 ? item.allPrice=(this.buyCarNum*item.price1).toFixed(2):item.allPrice=(this.buyCarNum*item.price2).toFixed(2);
                                    }else {
                                        item.price1 = item.PriceNumList[0].price;
                                        item.allPrice = (this.buyCarNum*item.price1).toFixed(2)
                                    }
                                    this.originalPrice += Number((this.buyCarNum*item.price1).toFixed(2))
                                    this.allMoney += Number(item.allPrice);
                                })
                                this.buyCarList = d.data.detail;
                                if(d.data.sourceID!=0){
                                    this.recommendSourceID = d.data.sourceID;
                                    let packagePrice = eval("(" + d.data.packagePrice + ")");
                                    let nowResInfo = {};
                                    nowResInfo.PriceNumList = [];
                                    packagePrice.forEach((one)=>{
                                        nowResInfo.PriceNumList.push({price:one.price,countNum:one.num,countBig:String(one.num).split('-')[1]||one.num});
                                    })
                                    nowResInfo.allPrice = 0;
                                    if(nowResInfo.PriceNumList.length==3){
                                        nowResInfo.price1 = nowResInfo.PriceNumList[0].price;
                                        nowResInfo.price2 = nowResInfo.PriceNumList[1].price;
                                        nowResInfo.price3 = nowResInfo.PriceNumList[2].price;

                                        nowResInfo.num1 = Number(nowResInfo.PriceNumList[0].countBig);
                                        nowResInfo.num2 = Number(nowResInfo.PriceNumList[1].countBig);
                                        nowResInfo.num3 = Number(nowResInfo.PriceNumList[2].countBig);

                                        nowResInfo.allPrice = nowResInfo.Num<nowResInfo.num1 ? nowResInfo.allPrice=(nowResInfo.Num*nowResInfo.price1).toFixed(2):nowResInfo.Num>nowResInfo.num3?nowResInfo.allPrice=(nowResInfo.Num*nowResInfo.price3).toFixed(2):nowResInfo.allPrice=(nowResInfo.Num*nowResInfo.price2).toFixed(2);
                                    }else if(nowResInfo.PriceNumList.length==2){
                                        nowResInfo.price1 = nowResInfo.PriceNumList[0].price;
                                        nowResInfo.price2 = nowResInfo.PriceNumList[1].price;

                                        nowResInfo.num1 = Number(nowResInfo.PriceNumList[0].countBig);
                                        nowResInfo.num2 = Number(nowResInfo.PriceNumList[1].countBig);

                                        nowResInfo.allPrice = nowResInfo.Num<nowResInfo.num1 ? nowResInfo.allPrice=(nowResInfo.Num*nowResInfo.price1).toFixed(2):nowResInfo.allPrice=(nowResInfo.Num*nowResInfo.price2).toFixed(2);
                                    }else {
                                        nowResInfo.price1 = nowResInfo.PriceNumList[0].price;
                                        nowResInfo.allPrice = (nowResInfo.Num*nowResInfo.price1).toFixed(2)
                                    }

                                    this.recommendBuyCar = nowResInfo;

                                    // 推荐计划合计价格
                                    if(this.recommendBuyCar.PriceNumList.length==3){
                                        this.allMoney = this.buyCarNum<=this.recommendBuyCar.num1 ? this.allMoney=(this.buyCarNum*this.recommendBuyCar.price1):this.buyCarNum<=this.recommendBuyCar.num2?this.allMoney=(this.buyCarNum*this.recommendBuyCar.price2):this.allMoney=(this.buyCarNum*this.recommendBuyCar.price3);
                                    }else if(this.recommendBuyCar.PriceNumList.length==2){
                                        this.allMoney = this.buyCarNum<=this.recommendBuyCar.num1 ? this.allMoney=(this.buyCarNum*this.recommendBuyCar.price1):this.allMoney=(this.buyCarNum*this.recommendBuyCar.price2);
                                    }else {
                                        this.allMoney = (this.buyCarNum*this.recommendBuyCar.price1);
                                    }
                                }

                            }else {
                                this.$message.error(d.msg)
                            }
                        });

                        this.dialogBigCar.centerDialogVisible = true;
                    }else {
                        this.$message.error(d.msg)
                    }
                })
            }

        },
        gotoInfo(one){
            if(one.usedStudyID){
                this.$router.push({name:'studyPlanInfo',query:{studyID:one.usedStudyID}})
            }else {
                this.$router.push({name:'studyNotApply',query:{commendID:one.study.CommendID}})
            }
        },
        countMinus(){
            if(this.buyCarNum>1){
                this.originalPrice = 0;
                this.allMoney = 0;
                this.buyCarNum--;
                this.buyCarList.forEach(one=>{
                    if(one.PriceNumList.length==3){
                        one.allPrice = this.buyCarNum<=one.num1 ? one.allPrice=(this.buyCarNum*one.price1).toFixed(2):this.buyCarNum<=one.num2?one.allPrice=(this.buyCarNum*one.price2).toFixed(2):one.allPrice=(this.buyCarNum*one.price3).toFixed(2);
                    }else if(one.PriceNumList.length==2){
                        one.allPrice = this.buyCarNum<=one.num1 ? one.allPrice=(this.buyCarNum*one.price1).toFixed(2):one.allPrice=(this.buyCarNum*one.price2).toFixed(2);
                    }else {
                        one.allPrice = (this.buyCarNum*one.price1).toFixed(2);
                    }
                    this.originalPrice += Number((this.buyCarNum*one.price1).toFixed(2))
                    this.allMoney+=Number(one.allPrice);
                })
                if(this.recommendSourceID!=0){
                    if(this.recommendBuyCar.PriceNumList.length==3){
                        this.allMoney = this.buyCarNum<=this.recommendBuyCar.num1 ? this.allMoney=(this.buyCarNum*this.recommendBuyCar.price1):this.buyCarNum<=this.recommendBuyCar.num2?this.allMoney=(this.buyCarNum*this.recommendBuyCar.price2):this.allMoney=(this.buyCarNum*this.recommendBuyCar.price3);
                    }else if(this.recommendBuyCar.PriceNumList.length==2){
                        this.allMoney = this.buyCarNum<=this.recommendBuyCar.num1 ? this.allMoney=(this.buyCarNum*this.recommendBuyCar.price1):this.allMoney=(this.buyCarNum*this.recommendBuyCar.price2);
                    }else {
                        this.allMoney = (this.buyCarNum*this.recommendBuyCar.price1);
                    }
                }
            }
        },
        countPlus(){
            this.originalPrice = 0;
            this.allMoney = 0;
            this.buyCarNum++;
            this.buyCarList.forEach(one=>{
                if(one.PriceNumList.length==3){
                    one.allPrice = this.buyCarNum<=one.num1 ? one.allPrice=(this.buyCarNum*one.price1).toFixed(2):this.buyCarNum<=one.num2?one.allPrice=(this.buyCarNum*one.price2).toFixed(2):one.allPrice=(this.buyCarNum*one.price3).toFixed(2);
                }else if(one.PriceNumList.length==2){
                    one.allPrice = this.buyCarNum<=one.num1 ? one.allPrice=(this.buyCarNum*one.price1).toFixed(2):one.allPrice=(this.buyCarNum*one.price2).toFixed(2);
                }else {
                    one.allPrice = (this.buyCarNum*one.price1).toFixed(2);
                }
                this.originalPrice += Number((this.buyCarNum*one.price1).toFixed(2))
                this.allMoney+=Number(one.allPrice);
            })
            if(this.recommendSourceID!=0){
                if(this.recommendBuyCar.PriceNumList.length==3){
                    this.allMoney = this.buyCarNum<=this.recommendBuyCar.num1 ? this.allMoney=(this.buyCarNum*this.recommendBuyCar.price1):this.buyCarNum<=this.recommendBuyCar.num2?this.allMoney=(this.buyCarNum*this.recommendBuyCar.price2):this.allMoney=(this.buyCarNum*this.recommendBuyCar.price3);
                }else if(this.recommendBuyCar.PriceNumList.length==2){
                    this.allMoney = this.buyCarNum<=this.recommendBuyCar.num1 ? this.allMoney=(this.buyCarNum*this.recommendBuyCar.price1):this.allMoney=(this.buyCarNum*this.recommendBuyCar.price2);
                }else {
                    this.allMoney = (this.buyCarNum*this.recommendBuyCar.price1);
                }
            }
        },
        countChange(){
            this.originalPrice = 0;
            this.allMoney = 0;
            if(Number(this.buyCarNum)<1){
                this.buyCarNum = 1;
            }
            this.buyCarList.forEach(one=>{
                if(one.PriceNumList.length==3){
                    one.allPrice = this.buyCarNum<=one.num1 ? one.allPrice=(this.buyCarNum*one.price1).toFixed(2):this.buyCarNum<=one.num2?one.allPrice=(this.buyCarNum*one.price2).toFixed(2):one.allPrice=(this.buyCarNum*one.price3).toFixed(2);
                }else if(one.PriceNumList.length==2){
                    one.allPrice = this.buyCarNum<=one.num1 ? one.allPrice=(this.buyCarNum*one.price1).toFixed(2):one.allPrice=(this.buyCarNum*one.price2).toFixed(2);
                }else {
                    one.allPrice = (this.buyCarNum*one.price1).toFixed(2);
                }
                this.originalPrice += Number((this.buyCarNum*one.price1).toFixed(2))
                this.allMoney+=Number(one.allPrice);
            })
            if(this.recommendSourceID!=0){
                if(this.recommendBuyCar.PriceNumList.length==3){
                    this.allMoney = this.buyCarNum<=this.recommendBuyCar.num1 ? this.allMoney=(this.buyCarNum*this.recommendBuyCar.price1):this.buyCarNum<=this.recommendBuyCar.num2?this.allMoney=(this.buyCarNum*this.recommendBuyCar.price2):this.allMoney=(this.buyCarNum*this.recommendBuyCar.price3);
                }else if(this.recommendBuyCar.PriceNumList.length==2){
                    this.allMoney = this.buyCarNum<=this.recommendBuyCar.num1 ? this.allMoney=(this.buyCarNum*this.recommendBuyCar.price1):this.allMoney=(this.buyCarNum*this.recommendBuyCar.price2);
                }else {
                    this.allMoney = (this.buyCarNum*this.recommendBuyCar.price1);
                }
            }
        },
        getList(){
            axios.post('/com/study/commendStudyList', qs.stringify({
                studyType:this.checkList.join(','),
                page:this.pageInfo.page,
                pagesize:this.pageInfo.pageSize
            })).then((res) => {
                var d = res.data;
                if(d.flag == 1){
                    this.list = d.data.Row;
                    this.pageInfo.total=Number(d.data.Total);
                }else {
                    this.$message.error(d.msg)
                }
            })
        }
    },
    mounted: function(){
        this.getList();
        this.$store.commit('setPath', this.path)
         // 设置tab切换
        this.$store.commit('setTab', this.tab)
        // 设置面包屑
        this.$store.commit('setTabCur', 1)

        axios.post('/com/study/getCommendStudyTypeList', qs.stringify({
        })).then((res) => {
            var d = res.data;
            if(d.flag == 1){
                this.kindList = d.data;
            }else {
                this.$message.error(d.msg)
            }
        })

    }
}


</script>
